Skip to content

Conversation

bhouston
Copy link
Member

@bhouston bhouston commented Mar 6, 2025

Description

This PR fixes a bug where the CLI tool would throw an error about the Anthropic API key not being set, even when using other LLM providers. The issue was caused by a hardcoded check for the Anthropic API key in the tool agent implementation that ran regardless of which provider was configured.

Changes

  1. Removed the hardcoded Anthropic API key check from toolAgentCore.ts
  2. Created a provider configuration map with API key names and documentation URLs
  3. Implemented a generic getProviderApiKeyError function that generates provider-specific error messages
  4. Updated the CLI command to use the provider config map for API key validation
  5. Maintained backward compatibility by keeping the getAnthropicApiKeyError function

Benefits of the Approach

  • Maintainability: Adding a new provider only requires adding an entry to the provider config map
  • Consistency: All provider error messages follow the same format
  • Flexibility: Provider-specific settings (key name, docs URL) are centralized
  • Simplicity: Reduced code duplication and simplified API key validation logic

Testing

  • Built the project successfully with pnpm build
  • The CLI will now only check for the API key of the currently selected LLM provider
  • Error messages include links to provider-specific documentation

Related Issues

Fixes #115

@bhouston bhouston merged commit e048fc7 into main Mar 6, 2025
1 check passed
Copy link

🎉 This PR is included in version mycoder-agent-v1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link

🎉 This PR is included in version mycoder-v1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bhouston bhouston deleted the fix/115-provider-specific-api-key-check branch March 12, 2025 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Anthropic API key check runs regardless of selected LLM provider

1 participant